{% extends "base_generic.html" %}

{% block title %}首页 - 本地图书馆{% endblock %}

{% block content %}
<div class="row mb-4">
    <div class="col-12">
        <div class="card">
            <div class="card-body text-black" style="background-color: #fff5cc;">
                <h1 class="card-title mb-4">
                    <i class="fas fa-book-reader" style="color: #ff69b4;"></i>
                    欢迎来到本地图书馆🐱
                </h1>
                <p class="lead">🐾在这里，你可以浏览图书、查看作者信息，并进行图书借阅。</p>
            </div>
        </div>
    </div>
</div>

<div class="row mb-4">
    <div class="col-md-4">
        <div class="card h-100">
            <div class="card-body text-center">
                <i class="fas fa-book fa-3x mb-3" style="color: #cce5ff;"></i>
                <h3>图书总数</h3>
                <p class="display-4">{{ num_books }}</p>
            </div>
        </div>
    </div>
    <div class="col-md-4">
        <div class="card h-100">
            <div class="card-body text-center">
                <i class="fas fa-users fa-3x mb-3" style="color: #FFDAB9;"></i>
                <h3>作者总数</h3>
                <p class="display-4">{{ num_authors }}</p>
            </div>
        </div>
    </div>
    <div class="col-md-4">
        <div class="card h-100">
            <div class="card-body text-center">
                <i class="fas fa-book fa-3x mb-3" style="color: #d9ffb3;"></i>
                <h3>可借图书</h3>
                <p class="display-4">{{ num_instances_available }}</p>
            </div>
        </div>
    </div>
</div>

<div class="row">
    <div class="col-md-6">
        <div class="card h-100">
            <div class="card-header text-white" style="background-color: #FFDEAD;">
                <h5 class="card-title mb-0">
                    <i class="fas fa-star me-2"></i>热门图书
                </h5>
            </div>
            <div class="card-body">
                <div class="list-group list-group-flush">
                    {% for book in books %}
                    <a href="{{ book.get_absolute_url }}" class="list-group-item list-group-item-action">
                        <div class="d-flex w-100 justify-content-between">
                            <h6 class="mb-1">{{ book.title }}</h6>
                            <small class="text-muted">{{ book.author }}</small>
                        </div>
                        <p class="mb-1 text-muted small">{{ book.summary|truncatewords:30 }}</p>
                    </a>
                    {% endfor %}
                </div>
            </div>
        </div>
    </div>
    <div class="col-md-6">
        <div class="card h-100">
            <div class="card-header text-white" style="background-color: #ffb3eb;">
                <h5 class="card-title mb-0">
                    <i class="fas fa-user-edit me-2"></i>知名作者
                </h5>
            </div>
            <div class="card-body">
                <div class="list-group list-group-flush">
                    {% for author in authors %}
                    <a href="{{ author.get_absolute_url }}" class="list-group-item list-group-item-action">
                        <div class="d-flex w-100 justify-content-between">
                            <h6 class="mb-1">{{ author.name }}</h6>
                            <small class="text-muted">
                                {% if author.date_of_birth %}{{ author.date_of_birth|date:"Y" }}{% endif %}
                                {% if author.date_of_death %}- {{ author.date_of_death|date:"Y" }}{% endif %}
                            </small>
                        </div>
                        <p class="mb-1 text-muted small">{{ author.bio|truncatewords:30 }}</p>
                    </a>
                    {% endfor %}
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %} 